import {city_data} from "./area.data";
// const city_data = [];
export const getProvinces = ()=>{
    console.log(city_data);
    const provinces = [];
    for (const province of city_data['province']){
        provinces.push({name: province.name,code:province.code});
    }
    return provinces;
}
export const getCitiesByProvince = (province:string)=>{
    // if(!province||!city_data[province]){
    //     return []
    // }
    if(!province){
        return [];
    }
    let cities = [];
    const val = city_data['province'];
    for (const city of val){
        if(city.code===province){
            cities = city['city'];
            break;
        } 
    }
    return cities;
}
export const getAreaByCity = (province:string,city:string)=>{
    // if(!province||!citydata[province]||!citydata[province][city]){
    //     return []
    // }
    if(!province||!city){
        return 
    }
    const val = city_data['province'];
    let cities = [];
    for(let c of val){
        if(c.code === province){
            cities = c['city'];
            for(let district of cities){
                if(district.code === city){
                      return district['county'];
                }
            }
        }
    }
}